#include "Comm.hpp"

int main()
{
    Fifo fifo(Path);
    int rfd = open(Path,O_RDONLY);
    if(rfd < 0)
    {
        cout << "open failed, errno: "<< errno << " , errstring :";
        cout << strerror(errno) << endl;
        return 1;
    }
    char buffer[1024];

    while(true)
    {
        ssize_t n = read(rfd,buffer,sizeof(buffer));
        if(n > 0)
        {
            buffer[n] = 0;
            cout << "Client say :" << buffer <<endl;
        }
        else if(n == 0)
        {
            cout << "Client quit, me too !!" <<endl;
            break;
        }
        else
        {
            cout << "read failed, errno: "<< errno << " , errstring :";
            break;
        }
    }

    close(rfd);
    return 0;
}
